package com.ylfstu.file;
import org.junit.jupiter.api.Test;

import java.io.File;
import java.io.IOException;

public class FileCreate {
    public static void main(String[] args) {


    }

    @Test
    public void create01() {
        String filePath = "F:\\YLF\\javastudy\\filestudy\\news1.txt";
        File file = new File(filePath);
        try {
            file.createNewFile();
            System.out.println("文件创建成功");
        } catch (IOException e) {
            e.printStackTrace();
            System.out.println("文件创建失败");
        }
    }

    @Test
    public void create02() {
        File parentFile = new File("F:\\YLF\\javastudy\\filestudy\\");
        String fileName = "news2.txt";
        File file = new File(parentFile, fileName);
        try {
            file.createNewFile();
            System.out.println("文件创建成功");
        } catch (IOException e) {
            e.printStackTrace();
            System.out.println("文件创建失败");
        }
    }

    @Test
    public void create03() {
        String parentPath = "F:\\YLF\\javastudy\\filestudy\\";
        String fileName = "news3.txt";
        File file = new File(parentPath, fileName);
        try {
            file.createNewFile();
            System.out.println("创建成功~");
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
